<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Philly Power Yoga | Power to Transform Your Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Find the power to transform your life with Philly Power Yoga. Your first class with us is FREE! Located in the beautiful Rittenhouse Square area of Philadelphia at 2016 Walnut Street, 2nd Floor." />
<meta name="keywords" content="philly power yoga, vinyasa yoga, power yoga, philadelphia yoga, philly yoga" />
<link rel="stylesheet" type="text/css" href="ppy2007.css" />
<script type="text/javascript" src="menu.js"></script>
<script src="js/jquery-1.2.6.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" >
 	
 // check to see if page is loaded before running code
 $(function() {
	
	var classTitles = [];
	var classTimes = [];
	var recurringData = [];
	var startTimes = [];
	
	var recurringEntry;
	
	var startTimeHour;
	var startTimeMinutes;
	var startTime;
	var setAmPm;
	
	var startTime = new Date();
    
	$.getJSON("http://www.google.com/calendar/feeds/1phillypoweryoga%40gmail.com/public/full?alt=json-in-script&callback=?&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true",
    
        function(json){	
		
			console.log(json);

            var html = '<p>Total of ' + json.feed.entry.length + ' event(s)</p>';
			var html = '<p>Location ' + json.feed.gd$where.valueString + '</p>';

            html += '<ul>';

			function listEvents(root) {
			    var feed = root.feed;
			    var entries = feed.entry || [];
			    var html = ['<ul>'];

			    for (var i = 0; i < entries.length; ++i) {
			      var entry = entries[i];
			      var title = entry.title.$t;
			      var start = (entry['gd$when']) ? entry['gd$when'][0].startTime : "";	

			      html.push('<li>', start, ' ', title, '</li>');
			    }

			    html.push('</ul>');
			    document.getElementById("agenda").innerHTML = html.join("");
			  }

            
            $.each(json.feed.entry,function(i,entry){
				
				//I want to show a complete event listing
				//Get title
				className = entry.title.$t;
				
				//a variable containing the regex for startTime is declared
				
				//need to get today's date
				//then display all events from that date + 6
			
			
				 if (entry.gd$recurrence != undefined) {
					
						recurringEntry = entry.gd$recurrence.$t;
						
						recurringData = recurringEntry.split(/[\r]/);
						
						startTime = recurringData[0].slice(-6,-2);
						
						startTimeMinutes = startTime.slice(-2);
						
						if (startTime > 1200) {
							
							setAmPm = "pm";
							
							//convert startTime to string	
							startTime = startTime - 1200 + "";
							
							//Just get first number, class never starts later than 8pm
							startTimeHour = startTime.slice(0,1);
	
							startTime = startTimeHour + ":" + startTimeMinutes + setAmPm;
							
						} else {
							
							setAmPm = "am";
							
							startTimeHour = startTime.slice(0,2);
	
							startTime = startTimeHour + ":" + startTimeMinutes + setAmPm;
							
						}
						
						//convert startTime to string : format for 12 hour day
						
						console.log("Time: " + startTime);
						
						startTimes.push(startTime);
						
				 } else {
					
				  		console.log("no reccurence");
				
				 }
							
				//get start time
				//use regular expression to parse this: DTSTART;TZID=America/New_York:20091002T120000\r\n
				//Format to 9:30am
				
				//get end time
                //parse this: DTEND;TZID=America/New_York:20091002T130000\r\n

    			html += '<li><span class="classTime">' + startTime + '</span><span class="className"> ' + className + '</span>';
				
				classTitles.push(entry.title.$t);
                
            }); //$.each
            
            html += '</ul>';
            
            $('#outputDiv').html(html);
        } //function(json)
    
    )//$.getJSON
    
	
    
}); // $(function() 
 
 </script>
 
</head>
<body>

<div class="containerschedule">
<!-- // begin navigation // -->
<div class="navcontainer">

</div>
<!-- // end navigation // -->
<div class="contentcontainer">
<div class="content">

<div class="schedulehome">
<h3>2016 Walnut Street  Schedule</h3>        

<select>
    <option value="Power Yoga">Power Yoga</option>
    <option value="Beginner Yoga">Beginner Yoga</option>
    <option value="Pilates">Pilates</option>
    <option value="Happy Hour">Happy Hour Yoga</option>
</select>

<div id="sampleFormat">
	<h2>Monday November 20, 2009</h2>
	<ul>
		<li>
			<span class="classTime">9:30am - 10:30am</span> 
			<span class="className">Power Yoga</span>
		</li>
		<li>
			<span class="classTime">12:00 - 1:00pm</span> 
			<span class="className">Pilates</span>
		</li>
	</ul>
</div>

<div id="outputDiv"></div>


</div>
</div>

</div>


</div>
</body>
</html>